package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.entity.ShopType;
import com.hmdp.service.IShopTypeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/shop-type")
public class ShopTypeController {
    @Resource
    private IShopTypeService typeService;

    /**
     * 店铺类型不是经常发生变化的内容，但是在首页会被经常查询，所以使用redis的string做缓存
     */
    @GetMapping("list")
    public Result queryTypeList() {
        List<ShopType> shopTypes = typeService.queryAllType();
        if(shopTypes!= null && !shopTypes.isEmpty()){
            return Result.ok(shopTypes);
        }
        return Result.fail("商铺类型数据为空");
    }
}
